import multiprocessing
#
# q=multiprocessing.Queue(3)#队列满了，再put会堵塞
# q.put('111')
# q.put(222)
# q.put([11,22,33])
# q.put(11)  堵塞
# print(q.full())
# print(q.get())
# print(q.get())
# print(q.get())
# # print(q.get())
#
# print(q.empty())

def download_from_web(q):
    '''模拟从网上下载数据'''
    data=[11,22,33,44]
    for i in data:
        q.put(i)
    print('----下载器已经下载完了数据并且存入队列中-----')


def analysis_data(q):
    '''数据处理'''
    waitting_analysis=list()
    while True:
        data=q.get()
        waitting_analysis.append(data)
        if q.empty():
            break
    print(waitting_analysis)
def mian():
    #创建一个队列
    q=multiprocessing.Queue()
    #2.创建多个进程，将队列的引用当做实参传递到里面
    p1=multiprocessing.Process(target=download_from_web,args=(q,))
    p2=multiprocessing.Process(target=analysis_data,args=(q,))
    p1.start()
    p2.start()

if __name__ == '__main__':
    mian()